package zwp.exercise.intereview.arraylist_intereview;

import com.alibaba.druid.sql.visitor.functions.Length;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Author zwp14
 * @create 2024/6/29 16:22
 * @description ArrayList扩容规则
 */
public class ArrayListDilatationRule {
    public static void main(String[] args) {

        //禁止在遍历(读)的时候进行写入更新操作
//        List<Integer> list = new ArrayList<>(List.of(1, 2, 3));
        //支持在遍历读取的时候,对list进行更改,读取只会读取最开始的list,写的时候会更新到另一个最新的list中(读写分离操作)
        List<Integer> integerList = new CopyOnWriteArrayList<>();
        List<Integer> list = new ArrayList<>();
//        List<Integer> temp = List.of(1, 2, 3);
        list.addAll(List.of(1,2,3));
        System.out.println("list = " + list);
        System.out.println();
        for (Integer integer : list) {
            System.out.println(integer);
        }
    }
}
